"""
rsa算法：
非对称加密算法，加密的秘钥和解密的秘钥是不一致的
加密使用公钥加密
解密使用私钥解密

"""



from Crypto.PublicKey import RSA

# 生成秘钥对
key_obj = RSA.generate(2048)
# print(key_obj, type(key_obj))

# 导出私钥
private_key = key_obj.export_key()
# print(private_key)
with open("private_key.pem", "wb") as fp:
    fp.write(private_key)

# 导出公钥
public_key = key_obj.public_key().export_key()
# print(public_key)
with open("public_key.pem", "wb") as fp:
    fp.write(public_key)

